import request from '@/utils/request'

/**
 * 开始训练了
 * @param mode
 * @param repoId
 * @param userId
 * @returns {*}
 */
export function startTrain(mode, repoId, userId, clear) {
  return request({
    url: '/exam/api/user/repo/start',
    method: 'post',
    data: { mode: mode, repoId: repoId, userId: userId, clear: clear }
  })
}

/**
 * 开始训练了
 * @param mode
 * @param repoId
 * @param userId
 * @returns {*}
 */
export function fillResult(id, answers, isRight) {
  return request({
    url: '/exam/api/user/repo/fill',
    method: 'post',
    data:  { id: id, answers: answers, isRight: isRight }
  })
}

/**
 * 是否存在训练
 * @param mode
 * @param repoId
 * @param userId
 * @returns {*}
 */
export function hasTrain(mode, repoId, userId) {
  return request({
    url: '/exam/api/user/repo/check',
    method: 'post',
    data:   { mode: mode, repoId: repoId, userId: userId }
  })
}

/**
 * 查找答题卡
 * @param mode
 * @param repoId
 * @param userId
 * @returns {*}
 */
export function listCard(mode, repoId, userId) {
  return request({
    url: '/exam/api/user/repo/card',
    method: 'post',
    data:   { mode: mode, repoId: repoId, userId: userId }
  })
}

/**
 * 下一题或者下一题
 * @param mode
 * @param repoId
 * @param userId
 * @param sequence
 * @returns {*}
 */
export function nextQu(mode, repoId, userId, sequence) {
  return request({
    url: '/exam/api/user/repo/next',
    method: 'post',
    data:  { mode: mode, repoId: repoId, userId: userId, sequence: sequence }
  })
}

